<?php defined('SYSPATH') or die('No direct script access.');

class Helper_MyConst {

	//////////////////////////////////////////////////
	// paths
	/////////////////////////////////////////////////
	public static $sep = '/';
	public static $upload_dir = array(
		'upload'	=> 'upload',
		'image'		=> 'images',
		'avatar'	=> 'avatars',
		'place'		=> 'placephotos'
	);
	
	
	static function upload_directory()
	{
		return $_SERVER['DOCUMENT_ROOT'] . Helper_MyConst::$sep . Helper_MyConst::$upload_dir['upload'] . Helper_MyConst::$sep;
	}
	
	static function upload_image_directory()
	{
		return  Helper_MyConst::upload_directory() . Helper_MyConst::$upload_dir['image'] . Helper_MyConst::$sep;
	}
	
	static function upload_avatar_directory()
	{
		return  Helper_MyConst::upload_image_directory() . Helper_MyConst::$upload_dir['avatar'] . Helper_MyConst::$sep;
	}
	
	static function upload_place_photo_directory()
	{
		return  Helper_MyConst::upload_image_directory() . Helper_MyConst::$upload_dir['place'] . Helper_MyConst::$sep;
	}
	
	static function local_path_2_url($path)
	{
		if (strpos($path, $_SERVER['DOCUMENT_ROOT']) == 0)
		{
			echo $path;
			echo $_SERVER['DOCUMENT_ROOT'];
		}
		
		return $path;
	}
	
	// display path
	static function upload_url()
	{
		return Helper_MyConst::$sep . Helper_MyConst::$upload_dir['upload'] . Helper_MyConst::$sep;
	}
	
	static function upload_image_url()
	{
		return Helper_MyConst::upload_url() . Helper_MyConst::$upload_dir['image'] . Helper_MyConst::$sep;
	}
	
	static function upload_avatar_url()
	{
		return Helper_MyConst::upload_image_url() . Helper_MyConst::$upload_dir['avatar'] . Helper_MyConst::$sep;
	}
	
	static function upload_place_photo_url()
	{
		return Helper_MyConst::upload_image_url() . Helper_MyConst::$upload_dir['place'] . Helper_MyConst::$sep;
	}
	
	
	//////////////////////////////////////////////////
	// Entity type
	/////////////////////////////////////////////////
	const ENTITY_TYPE_TASK         	  = 101;
	const ENTITY_TYPE_COMMENT		  = 102;
	const ENTITY_TYPE_MILESTONE		  = 103;
	
	static $ENTITY_TYPE_TABLE = array(
		Helper_MyConst::ENTITY_TYPE_TASK 		   => 'task',
		Helper_MyConst::ENTITY_TYPE_COMMENT 	   => 'e_comment',
		Helper_MyConst::ENTITY_TYPE_MILESTONE 	   => 'milestone',
	);
	
	static $ENTITY_TYPE_VIEW = array(
		Helper_MyConst::ENTITY_TYPE_TASK 		   => 'entity_task',
		Helper_MyConst::ENTITY_TYPE_COMMENT 	   => 'entity_comment',
		Helper_MyConst::ENTITY_TYPE_MILESTONE 	   => 'entity_milestone',
	);
	
	static $LINK_TYPE_TABLE = array(
		Helper_MyConst::ENTITY_TYPE_TASK 		   => '/t/view',
	);

	//////////////////////////////////////////////////
	// Project type
	/////////////////////////////////////////////////
	const PROJECT_MANAGER 	= 001;
	const PROJECT_ADMIN 	= 002;
	const PROJECT_EMPLOYEE 	= 003;
	
	const PROJECT_ACCESS = 006;
	const PROJECT_REMOVE = 007;
	
	static $ID_2_PROJECT_ROLE = array(
		Helper_MyConst::PROJECT_MANAGER 	=> 'Project manager',
		Helper_MyConst::PROJECT_ADMIN 		=> 'Project adimin',
		Helper_MyConst::PROJECT_EMPLOYEE 	=> 'Project employee'
	);
	//////////////////////////////////////////////////
	// Task type
	/////////////////////////////////////////////////
	const TASK_DONE 		= 10;
	const TASK_ON_PROGRESS	= 11;
	const TASK_SUSPENDED	= 12;
	const TASK_LATE			= 13;
	
	static $TASK_STATUS_TABLE = array (
		Helper_MyConst::TASK_DONE 			=> 'Done',
		Helper_MyConst::TASK_ON_PROGRESS    => 'On Progress',
		Helper_MyConst::TASK_SUSPENDED  	=> 'Suspended',
		Helper_MyConst::TASK_LATE 			=> 'Late',
	);
	const TASK_PROJECT_NAME 			= 550;
	const TASK_PEOPLE 					= 551;
	const TASK_TASKS 					= 552;
	const TASK_ASSIGNED_FROM 			= 553;
	const TASK_PRIORITY 				= 554;
	const TASK_DEADLINE 				= 555;
	const TASK_STATUS	 				= 556;
	
	
	static $TASK_OPTION_2_NAME = array(
		Helper_MyConst::TASK_PROJECT_NAME 		   		=> 'project_name',
		Helper_MyConst::TASK_PEOPLE 		   			=> 'assign_user_displayname',
		Helper_MyConst::TASK_TASKS						=> 'name',
		Helper_MyConst::TASK_ASSIGNED_FROM 		   		=> 'user_displayname',
		Helper_MyConst::TASK_PRIORITY 					=> 'priority',
		Helper_MyConst::TASK_DEADLINE 		   			=> 'deadline',
		Helper_MyConst::TASK_STATUS 					=> 'assign_task_status',
	);
	//////////////////////////////////////////////////
	// project type
	/////////////////////////////////////////////////
	const IN_PROJECT = 1;
	const NOT_IN_PROJECT = 0;
	
	const TECHNICAL 	= 100;
	const GENERAL		= 101;
	const FINANCE		= 102;
	static $PROJECT_TYPE_TABLE = array (
		Helper_MyConst::TECHNICAL => 'Technical',
		Helper_MyConst::GENERAL   => 'General',
		Helper_MyConst::FINANCE   => 'Finance',
	);
	
	const PRIORITY_HIGH 	= 110;
	const PRIORITY_MEDIUM 	= 111;
	const PRIORITY_LOW 		= 112;
	
	static $PROJECT_PRIORITY_TABLE = array (
		Helper_MyConst::PRIORITY_HIGH 		=> 'High',
		Helper_MyConst::PRIORITY_MEDIUM   	=> 'Medium',
		Helper_MyConst::PRIORITY_LOW   		=> 'Low',
	);
	
	const STATUS_DELAY 			= 120;
	const STATUS_IN_PROGRESS 	= 121;
	const STATUS_COMPLETE 		= 122;
	
	static $PROJECT_STATUS_TABLE = array (
		Helper_MyConst::STATUS_DELAY 		=> 'Delay',
		Helper_MyConst::STATUS_IN_PROGRESS  => 'On progress',
		Helper_MyConst::STATUS_COMPLETE   	=> 'Complete',
	);	
	
	const SCALE_VERY_BIG 		= 123;
	const SCALE_BIG 			= 124;
	const SCALE_MEDIUM 			= 125;
	const SCALE_SMALL 			= 126;
	const SCALE_VERY_SMALL 		= 127;
	
	static $PROJECT_SCALE_TABLE = array (
		Helper_MyConst::SCALE_VERY_BIG 		=> 'Very big',
		Helper_MyConst::SCALE_BIG   		=> 'Big',
		Helper_MyConst::SCALE_MEDIUM   		=> 'Medium',
		Helper_MyConst::SCALE_SMALL   		=> 'Small',
		Helper_MyConst::SCALE_VERY_SMALL   	=> 'Very small'
	);
	
	const PROJECT_NAME 					= 500;
	const PROJECT_ID 					= 501;
	const PROJECT_TYPE 					= 502;
	const PROJECT_PRIORITY 				= 503;
	const PROJECT_PROGRESS 				= 504;
	const PROJECT_SCALE 				= 505;
	const PROJECT_STATUS	 			= 506;
	const PROJECT_ESTIMATE_START_DATE 	= 507;
	const PROJECT_ESTIMATE_END_DATE 	= 508;
	const PROJECT_ACTUAL_START_DATE 	= 509;
	const PROJECT_ACTUAL_END_DATE 		= 510;
	
	static $PROJECT_OPTION_2_NAME = array(
		Helper_MyConst::PROJECT_NAME 		   			=> 'name',
		Helper_MyConst::PROJECT_ID 		   				=> 'id',
		Helper_MyConst::PROJECT_TYPE					=> 'type',
		Helper_MyConst::PROJECT_PRIORITY 		   		=> 'priority',
		Helper_MyConst::PROJECT_PROGRESS 				=> 'progress',
		Helper_MyConst::PROJECT_SCALE 		   			=> 'scale',
		Helper_MyConst::PROJECT_STATUS 					=> 'status',
		Helper_MyConst::PROJECT_ESTIMATE_START_DATE 	=> 'date_create',
		Helper_MyConst::PROJECT_ESTIMATE_END_DATE 		=> 'deadline',
		Helper_MyConst::PROJECT_ACTUAL_START_DATE 		=> 'date_start',
		Helper_MyConst::PROJECT_ACTUAL_END_DATE 		=> 'date_finish',
	);
	//////////////////////////////////////////////////
	// organization title
	/////////////////////////////////////////////////
	const ORGANIZATION_OWNER = 650;
	
	const ORGANIZATION_ACCESS = 600;
	const ORGANIZATION_REMOVE = 601;
	//////////////////////////////////////////////////
	// user priveledges
	/////////////////////////////////////////////////
	static function USER_PRIVILEDGE($project_id = NULL, $user_id )
	{
		if (isset($project_id))
		{
			$project_info = Model::factory('project')->get_project_info($project_id);
			$project_name = $project_info['name']; 
			$p = '/project/';
		} else {
			$project_name = 'All'; 
			$p='/project';
		}
		
		
		$functions = array(
			array(
				'controller' => '/about', 
				'name' => 'About', 
				'class' => '',
				'id'	=> Helper_MyConst::TAB_ABOUT
			),
			array(
				'controller' => $p.$project_id, 
				'name' => 'Project ('.$project_name.')', 
				'class' => '',
				'id'	=> Helper_MyConst::TAB_PROJECT_NAME
			),
			array(
				'controller' => $p.$project_id.'/hot_tits', 
				'name' => 'Hot tips', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_HOT_TIPS
			),
			array(
				'controller' => $p.$project_id.'/milestones', 
				'name' => 'Milestones', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_MILESTONES
			),
			array(
				'controller' => $p.$project_id.'/people', 
				'name' => 'People', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_PEOPPLE
			),
			/*array(
				'controller' => $p.$project_id.'/tasks_requests', 
				'name' => 'Tasks/requests', 
				'class' => 'child',
			),*/
			array(
				'controller' => $p.$project_id.'/tasks',
				'name' => 'Tasks', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_TASKS
			),
			/*array(
				'controller' => $p.$project_id.'/requests', 
				'name' => 'Requests', 
				'class' => 'grand',
				'id'	=> Helper_MyConst::TAB_REQUESTS
			),*/
			//array('controller' => $p.$project_id.'/gantt_chart', 'name' => 'Gantt chart', 'class' => 'child'),
			array(
				'controller' => $p.$project_id.'/documents', 
				'name' => 'Documents', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_DOCUMENTS
			),
			array(
				'controller' => $p.$project_id.'/reports', 
				'name' => 'Reports', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_REPORT
			),
			array(
				'controller' => $p.$project_id.'/setting', 
				'name' => 'Setting', 
				'class' => 'child',
				'id'	=> Helper_MyConst::TAB_SETTING
			),
			//array('controller' => '/past_projects', 'name' => 'All past projects', 'class' => ''),
			array(
				'controller' => '/announcement', 
				'name' => 'Announcement', 
				'class' => '',
				'id'	=> Helper_MyConst::TAB_ANNOUNCEMENT
			),
		);
		return $functions;
	}
	const TAB_ABOUT 		= 150;
	const TAB_PROJECT_NAME 	= 151;
	const TAB_HOT_TIPS 		= 152;
	const TAB_MILESTONES 	= 153;
	const TAB_PEOPPLE 		= 155;
	const TAB_TASKS 		= 156;
	const TAB_REQUESTS 		= 157;
	const TAB_DOCUMENTS 	= 158;
	const TAB_REPORT	 	= 159;
	const TAB_ANNOUNCEMENT 	= 160;
	const TAB_SETTING 		= 161;
	
	static $EMPLOYEE_PEOPLE_PRIVILEDGE = array(
		array('controller' => '/user/overview'),
		Helper_MyConst::ENTITY_TYPE_COMMENT 	   => 'e_comment',
	);
	
	
	
	//////////////////////////////////////////////////
	// User info relating table
	/////////////////////////////////////////////////
	static $USER_RELATING_TABLE = array(
		'project', 'task_project', 'e_comment', 'task' 
	);
	
	
	
	
}
